package com.zhaoxi.project.wms.controller;

import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.project.wms.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

// * 样例信息操作处理
@RestController
@RequestMapping("/wms/stock")
public class StockController extends BaseService {
  @Autowired
  private StockService stockService;

  //  获列表
  @PreAuthorize("@ss.hasPermi('wms:stock:list')")
  @GetMapping("/getList")
  public PageData getList(Map map) {
    PageData pd = this.getPageData(map);
    //如果 pageNum 和 pageSize 都是有值的，就是需要分页的
    if (pd.getLong("pageNum") != null && pd.getLong("pageSize") != null){
      this.startPage();
    }
    return this.responses(stockService.getList(pd));
  }


  //  修改
  @PreAuthorize("@ss.hasPermi('wms:stock:edit')")
  @Log(title = "执行库存相关订单", businessType = BusinessType.UPDATE)
  @PutMapping("/editForOrderExec")
  public PageData editForOrderExec(@RequestBody Map map) {
    PageData pd = this.getPageData(map);
    return stockService.editForOrderExec(pd);
  }


  //  获行数
  @PreAuthorize("@ss.hasPermi('wms:stock:list')")
  @GetMapping("/getCount")
  public PageData getCount(Map map) {
    PageData pd = this.getPageData(map);
    return stockService.getCount(pd);
  }

  // 库存日志记录信息==================================
  @PreAuthorize("@ss.hasPermi('wms:stock:list')")
  @GetMapping("/getLogPage")
  public PageData getLogPage(Map map) {
    PageData pd = this.getPageData(map);
    startPage();
    return stockService.getLogList(pd);
  }

  //  获列表
  @PreAuthorize("@ss.hasPermi('wms:stock:list')")
  @GetMapping("/getLogList")
  public PageData getLogList(Map map) {
    PageData pd = this.getPageData(map);
    return stockService.getLogList(pd);
  }

  //  获行数
  @PreAuthorize("@ss.hasPermi('wms:stock:list')")
  @GetMapping("/getLogCount")
  public PageData getLogCount(Map map) {
    PageData pd = this.getPageData(map);
    return stockService.getLogCount(pd);
  }
}
